package com.cz.modules.rll.controller;

import java.util.Arrays;
import java.util.Map;

import com.cz.common.validator.ValidatorUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.cz.modules.rll.entity.RllPlaceEntity;
import com.cz.modules.rll.service.RllPlaceService;
import com.cz.common.utils.PageUtils;
import com.cz.common.utils.R;



/**
 * 人流量位置管理
 *
 * @author Cz
 * @email 
 * @date 2020-04-26 20:25:44
 */
@RestController
@RequestMapping("rll/rllplace")
public class RllPlaceController {
    @Autowired
    private RllPlaceService rllPlaceService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("rll:rllplace:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = rllPlaceService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("rll:rllplace:info")
    public R info(@PathVariable("id") String id){
        RllPlaceEntity rllPlace = rllPlaceService.getById(id);

        return R.ok().put("rllPlace", rllPlace);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("rll:rllplace:save")
    public R save(@RequestBody RllPlaceEntity rllPlace){
        rllPlaceService.save(rllPlace);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("rll:rllplace:update")
    public R update(@RequestBody RllPlaceEntity rllPlace){
        ValidatorUtils.validateEntity(rllPlace);
        rllPlaceService.updateById(rllPlace);
        
        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("rll:rllplace:delete")
    public R delete(@RequestBody String[] ids){
        rllPlaceService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
